package app.netant.book.fd34;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
import app.netant.book.base.BaseEntity;
import app.netant.book.base.BasePage;
import app.portal.system.sysmsg.sysMessage;
import cn.lily.com.enviroment.Enviroment;

public class Fd34Page extends BasePage {

	public Fd34Page(String netSite) {
		super(netSite);
		this.tableKey = "fd34";
		this.selectKey = ".sort .left .list .listable .dysx1 strong a";
		this.preHref = "http://www.34fd.com";
	}

	@Override
	public String buildHref(Element element) {	
		String href = element.attr("href");
		if(href.startsWith("/")){
			href = this.preHref + href;
		}
		return href;
	}

	@Override
	public BaseEntity buildEntity() {
		return new Fd34Entity();
	}

	@Override
	public BaseDetail buildDetail(String href) {
		return new Fd34Detail(href);
	}

	@Override
	public void afterEntity(BaseEntity entity, Element element) {
		Elements parts = element.parent().parent().nextElementSibling().select("font[color='#777777']");
		if(parts.size()>0){
			String memo = parts.text();
			System.out.println("【Memo】:"+memo);
			entity.setNovelMemo(memo);
		}
	}
	
	public static void main(String[] args) {
		Enviroment.createEnv();
		Enviroment.getEnv().getLogBean().beginLog();
		Fd34Page page = new Fd34Page("http://www.34fd.com/xhxz/1.html");
		page.analyseHref();
	}
	
}
